package com.czxy.demo02;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;

/**
 * Created by hp on 2020/1/30.
 */
public class Test07 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        Random rd = new Random();
        while (true){
            Scanner sc = new Scanner(System.in);
            System.out.println("1.发牌");
            System.out.println("2.结束发牌");
            int i = sc.nextInt();
            if (i==1){
                int s = rd.nextInt(13) + 1;
                list.add(s);

                int a=0;
                for (Integer b : list) {
                    a+=b;
                }
                if (a>21){
                    System.out.println("点数为:"+a+",大于21结束游戏");
                    break;
                }else {
                    System.out.println("手上的牌有: ");
                    for (Integer b2 : list) {
                        System.out.println(b2+",");
                    }
                    System.out.println("点数和为"+a);
                }
            }else if (i==2){
                System.out.println("您手上的牌有: ");
                int sum = 0;
                for (Integer b3 : list) {
                    System.out.println(b3+", ");
                    sum+=b3;
                }
                System.out.println("点数为"+sum);
                break;
            }
        }
    }
}
